package com.test;

import java.awt.*;
import java.awt.event.*;
import java.awt.font.*;
import java.awt.geom.*;
import javax.swing.*;

public class latihan extends JPanel {

    public latihan() {
        setBackground(Color.white);

    }

    public void paintComponent(Graphics g) {
        super.paintComponent(g);
        g.setColor(Color.BLUE);
        g.drawRect(20, 30, 130, 70);
        g.setColor(Color.BLUE);
        g.drawRect(150, 60, 45, 40);
        g.setColor(Color.GREEN);
        g.drawRect(40, 40, 25, 20);
        g.setColor(Color.GREEN);
        g.drawRect(80, 40, 25, 20);
        g.setColor(Color.MAGENTA);
        g.drawRect(115, 40, 25, 55);
        g.setColor(Color.CYAN);
        g.drawOval(45, 85, 40, 40);
        g.setColor(Color.CYAN);
        g.drawOval(140, 85, 40, 40);
//        g.setColor(new Color(255, 0, 0));
//        g.fillOval(100, 10, 50, 50);
//        g.setColor(new Color(0, 255, 0));
//        g.fillArc(150, 10, 50, 50, 0, 180);
        Graphics2D g2 = (Graphics2D) g;
//// fill RoundRectangle2D.Double
        GradientPaint redtowhite = new GradientPaint(200, 10, Color.red, 250, 10, Color.black);
        g2.setPaint(redtowhite);
//        g2.fill(new RoundRectangle2D.Double(200, 10, 50, 50, 10, 10));
////g2.setPaint();
        g2.drawString("Bus Sekolaaahhh...", 200, 80);
//        g2.setFont(new Font("Dialog", Font.TYPE1_FONT, 20));
//    }
//

    }

    public static void main(String args[]) {
        JFrame frame = new JFrame("Grafik 2 Dimensi");
        frame.addWindowListener(new WindowAdapter() {
            @Override
            public void windowClosing(WindowEvent e) {
                System.exit(0);
            }
        });
        frame.setLayout(new BorderLayout());
        latihan l = new latihan();
        frame.add(l, BorderLayout.CENTER);
        frame.setSize(450, 250);
        frame.setVisible(true);
    }
}
